home *** CD-ROM | disk | FTP | other *** search
-
- package require -exact Tk 8.4
- package require -exact Tcl 8.4
-
- namespace eval ::tk {
- namespace eval msgcat {
- namespace export mc mcmax
- if {[interp issafe] || [catch {package require msgcat}]} {
- proc mc {src args} {
- return [eval [list format $src] $args]
- }
- proc mcmax {args} {
- set max 0
- foreach string $args {
- set len [string length $string]
- if {$len>$max} {
- set max $len
- }
- }
- return $max
- }
- } else {
- namespace import ::msgcat::mc
- namespace import ::msgcat::mcmax
- ::msgcat::mcload [file join $::tk_library msgs]
- }
- }
- namespace import ::tk::msgcat::*
- }
-
-
- if {[info exists ::auto_path] && [string compare {} $::tk_library] && [lsearch -exact $::auto_path $::tk_library] < 0} {
- lappend ::auto_path $::tk_library
- }
-
-
- set ::tk_strictMotif 0
-
-
- catch {tk useinputmethods 1}
-
- proc ::tk::PlaceWindow {w {place ""} {anchor ""}} {
- wm withdraw $w
- update idletasks
- set checkBounds 1
- if {$place eq ""} {
- set x [expr {([winfo screenwidth $w]-[winfo reqwidth $w])/2}]
- set y [expr {([winfo screenheight $w]-[winfo reqheight $w])/2}]
- set checkBounds 0
- } elseif {[string equal -len [string length $place] $place "pointer"]} {
- if {[string equal -len [string length $anchor] $anchor "center"]} {
- set x [expr {[winfo pointerx $w]-[winfo reqwidth $w]/2}]
- set y [expr {[winfo pointery $w]-[winfo reqheight $w]/2}]
- } else {
- set x [winfo pointerx $w]
- set y [winfo pointery $w]
- }
- } elseif {[string equal -len [string length $place] $place "widget"] && [winfo exists $anchor] && [winfo ismapped $anchor]} {
- set x [expr {[winfo rootx $anchor] + ([winfo width $anchor]-[winfo reqwidth $w])/2}]
- set y [expr {[winfo rooty $anchor] + ([winfo height $anchor]-[winfo reqheight $w])/2}]
- } else {
- set x [expr {([winfo screenwidth $w]-[winfo reqwidth $w])/2}]
- set y [expr {([winfo screenheight $w]-[winfo reqheight $w])/2}]
- set checkBounds 0
- }
- if {[tk windowingsystem] eq "win32"} {
- set checkBounds 0
- }
- if {$checkBounds} {
- if {$x < 0} {
- set x 0
- } elseif {$x > ([winfo screenwidth $w]-[winfo reqwidth $w])} {
- set x [expr {[winfo screenwidth $w]-[winfo reqwidth $w]}]
- }
- if {$y < 0} {
- set y 0
- } elseif {$y > ([winfo screenheight $w]-[winfo reqheight $w])} {
- set y [expr {[winfo screenheight $w]-[winfo reqheight $w]}]
- }
- if {[tk windowingsystem] eq "macintosh" || [tk windowingsystem] eq "aqua"} {
- if {$y < 20} { set y 20 }
- }
- }
- wm geometry $w +$x+$y
- wm deiconify $w
- }
-
- proc ::tk::SetFocusGrab {grab {focus {}}} {
- set index "$grab,$focus"
- upvar ::tk::FocusGrab($index) data
-
- lappend data [focus]
- set oldGrab [grab current $grab]
- lappend data $oldGrab
- if {[winfo exists $oldGrab]} {
- lappend data [grab status $oldGrab]
- }
- catch {grab $grab}
- if {[winfo exists $focus]} {
- focus $focus
- }
- }
-
- proc ::tk::RestoreFocusGrab {grab focus {destroy destroy}} {
- set index "$grab,$focus"
- if {[info exists ::tk::FocusGrab($index)]} {
- foreach {oldFocus oldGrab oldStatus} $::tk::FocusGrab($index) { break }
- unset ::tk::FocusGrab($index)
- } else {
- set oldGrab ""
- }
-
- catch {focus $oldFocus}
- grab release $grab
- if {[string equal $destroy "withdraw"]} {
- wm withdraw $grab
- } else {
- destroy $grab
- }
- if {[winfo exists $oldGrab] && [winfo ismapped $oldGrab]} {
- if {[string equal $oldStatus "global"]} {
- grab -global $oldGrab
- } else {
- grab $oldGrab
- }
- }
- }
-
- if {[string equal $tcl_platform(platform) "unix"]} {
- proc ::tk::GetSelection {w {sel PRIMARY}} {
- if {[catch {selection get -displayof $w -selection $sel -type UTF8_STRING} txt] && [catch {selection get -displayof $w -selection $sel} txt]} {
- return -code error "could not find default selection"
- } else {
- return $txt
- }
- }
- } else {
- proc ::tk::GetSelection {w {sel PRIMARY}} {
- if {[catch {selection get -displayof $w -selection $sel} txt]} {
- return -code error "could not find default selection"
- } else {
- return $txt
- }
- }
- }
-
-
- proc ::tk::ScreenChanged screen {
- set x [string last . $screen]
- if {$x > 0} {
- set disp [string range $screen 0 [expr {$x - 1}]]
- } else {
- set disp $screen
- }
-
- uplevel #0 upvar #0 ::tk::Priv.$disp ::tk::Priv
- variable ::tk::Priv
- global tcl_platform
-
- if {[info exists Priv]} {
- set Priv(screen) $screen
- return
- }
- array set Priv {
- activeMenu {}
- activeItem {}
- afterId {}
- buttons 0
- buttonWindow {}
- dragging 0
- focus {}
- grab {}
- initPos {}
- inMenubutton {}
- listboxPrev {}
- menuBar {}
- mouseMoved 0
- oldGrab {}
- popup {}
- postedMb {}
- pressX 0
- pressY 0
- prevPos 0
- selectMode char
- }
- set Priv(screen) $screen
- set Priv(tearoff) [string equal [tk windowingsystem] "x11"]
- set Priv(window) {}
- }
-
-
- tk::ScreenChanged [winfo screen .]
-
-
- proc ::tk::EventMotifBindings {n1 dummy dummy} {
- upvar $n1 name
-
- if {$name} {
- set op delete
- } else {
- set op add
- }
-
- event $op <<Cut>> <Control-Key-w>
- event $op <<Copy>> <Meta-Key-w>
- event $op <<Paste>> <Control-Key-y>
- event $op <<Undo>> <Control-underscore>
- }
-
-
- if {[string equal [info commands tk_chooseColor] ""]} {
- proc ::tk_chooseColor {args} {
- return [eval tk::dialog::color:: $args]
- }
- }
- if {[string equal [info commands tk_getOpenFile] ""]} {
- proc ::tk_getOpenFile {args} {
- if {$::tk_strictMotif} {
- return [eval tk::MotifFDialog open $args]
- } else {
- return [eval ::tk::dialog::file:: open $args]
- }
- }
- }
- if {[string equal [info commands tk_getSaveFile] ""]} {
- proc ::tk_getSaveFile {args} {
- if {$::tk_strictMotif} {
- return [eval tk::MotifFDialog save $args]
- } else {
- return [eval ::tk::dialog::file:: save $args]
- }
- }
- }
- if {[string equal [info commands tk_messageBox] ""]} {
- proc ::tk_messageBox {args} {
- return [eval tk::MessageBox $args]
- }
- }
- if {[string equal [info command tk_chooseDirectory] ""]} {
- proc ::tk_chooseDirectory {args} {
- return [eval ::tk::dialog::file::chooseDir:: $args]
- }
- }
-
-
- switch [tk windowingsystem] {
- "x11" {
- event add <<Cut>> <Control-Key-x> <Key-F20>
- event add <<Copy>> <Control-Key-c> <Key-F16>
- event add <<Paste>> <Control-Key-v> <Key-F18>
- event add <<PasteSelection>> <ButtonRelease-2>
- event add <<Undo>> <Control-Key-z>
- event add <<Redo>> <Control-Key-Z>
- catch { event add <<PrevWindow>> <ISO_Left_Tab> }
- catch { event add <<PrevWindow>> <hpBackTab> }
-
- trace variable ::tk_strictMotif w ::tk::EventMotifBindings
- set ::tk_strictMotif $::tk_strictMotif
- }
- "win32" {
- event add <<Cut>> <Control-Key-x> <Shift-Key-Delete>
- event add <<Copy>> <Control-Key-c> <Control-Key-Insert>
- event add <<Paste>> <Control-Key-v> <Shift-Key-Insert>
- event add <<PasteSelection>> <ButtonRelease-2>
- event add <<Undo>> <Control-Key-z>
- event add <<Redo>> <Control-Key-y>
- }
- "aqua" {
- event add <<Cut>> <Command-Key-x> <Key-F2>
- event add <<Copy>> <Command-Key-c> <Key-F3>
- event add <<Paste>> <Command-Key-v> <Key-F4>
- event add <<PasteSelection>> <ButtonRelease-2>
- event add <<Clear>> <Clear>
- event add <<Undo>> <Command-Key-z>
- event add <<Redo>> <Command-Key-y>
- }
- "classic" {
- event add <<Cut>> <Control-Key-x> <Key-F2>
- event add <<Copy>> <Control-Key-c> <Key-F3>
- event add <<Paste>> <Control-Key-v> <Key-F4>
- event add <<PasteSelection>> <ButtonRelease-2>
- event add <<Clear>> <Clear>
- event add <<Undo>> <Control-Key-z> <Key-F1>
- event add <<Redo>> <Control-Key-Z>
- }
- }
-
- if {$::tk_library ne ""} {
- if {[string equal $tcl_platform(platform) "macintosh"]} {
- proc ::tk::SourceLibFile {file} {
- if {[catch {
- namespace eval :: [list source [file join $::tk_library $file.tcl]]
- }]} {
- namespace eval :: [list source -rsrc $file]
- }
- }
- } else {
- proc ::tk::SourceLibFile {file} {
- namespace eval :: [list source [file join $::tk_library $file.tcl]]
- }
- }
- namespace eval ::tk {
- SourceLibFile button
- SourceLibFile entry
- SourceLibFile listbox
- SourceLibFile menu
- SourceLibFile panedwindow
- SourceLibFile scale
- SourceLibFile scrlbar
- SourceLibFile spinbox
- SourceLibFile text
- }
- }
-
- event add <<PrevWindow>> <Shift-Tab>
- bind all <Tab> {tk::TabToWindow [tk_focusNext %W]}
- bind all <<PrevWindow>> {tk::TabToWindow [tk_focusPrev %W]}
-
-
- proc ::tk::CancelRepeat {} {
- variable ::tk::Priv
- after cancel $Priv(afterId)
- set Priv(afterId) {}
- }
-
-
- proc ::tk::TabToWindow {w} {
- if {[string equal [winfo class $w] Entry] || [string equal [winfo class $w] Spinbox]} {
- $w selection range 0 end
- $w icursor end
- }
- focus $w
- }
-
- proc ::tk::UnderlineAmpersand {text} {
- set idx [string first "&" $text]
- if {$idx >= 0} {
- set underline $idx
- while {[string match "&" [string index $text [expr {$idx + 1}]]]} {
- set base [expr {$idx + 2}]
- set idx [string first "&" [string range $text $base end]]
- if {$idx < 0} {
- break
- } else {
- set underline [expr {$underline + $idx + 1}]
- incr idx $base
- }
- }
- }
- if {$idx >= 0} {
- regsub -all -- {&([^&])} $text {\1} text
- }
- return [list $text $idx]
- }
-
- proc ::tk::SetAmpText {widget text} {
- foreach {newtext under} [::tk::UnderlineAmpersand $text] {
- $widget configure -text $newtext -underline $under
- }
- }
-
- proc ::tk::AmpWidget {class path args} {
- set wcmd [list $class $path]
- foreach {opt val} $args {
- if {[string equal $opt {-text}]} {
- foreach {newtext under} [::tk::UnderlineAmpersand $val] {
- lappend wcmd -text $newtext -underline $under
- }
- } else {
- lappend wcmd $opt $val
- }
- }
- eval $wcmd
- if {$class=="button"} {
- bind $path <<AltUnderlined>> [list $path invoke]
- }
- return $path
- }
-
- proc ::tk::FindAltKeyTarget {path char} {
- switch [winfo class $path] {
- Button -
- Label {
- if {[string equal -nocase $char [string index [$path cget -text] [$path cget -underline]]]} {return $path} else {return {}}
- }
- default {
- foreach child [concat [grid slaves $path] [pack slaves $path] [place slaves $path] ] {
- if {""!=[set target [::tk::FindAltKeyTarget $child $char]]} {
- return $target
- }
- }
- }
- }
- return {}
- }
-
- proc ::tk::AltKeyInDialog {path key} {
- set target [::tk::FindAltKeyTarget $path $key]
- if { $target == ""} return
- event generate $target <<AltUnderlined>>
- }
-
-
- proc ::tk::mcmaxamp {args} {
- set maxlen 0
- foreach arg $args {
- set length [string length [lindex [::tk::UnderlineAmpersand [mc $arg]] 0]]
- if {$length>$maxlen} {
- set maxlen $length
- }
- }
- return $maxlen
- }
-
- if {[string equal [tk windowingsystem] "aqua"]} {
- namespace eval ::tk::mac {
- set useCustomMDEF 0
- }
- }
-